<div class="leaderboard">
  <div class="page__header">
    <h1 class="page__title">{{this.model.leaderboard.name}}</h1>
    <DButton
      @action={{action "showLeaderboardInfo"}}
      class="-ghost"
      @icon="info-circle"
      @label={{unless site.mobileView "gamification.leaderboard.info"}}
    />

    {{#if this.currentUser.staff}}
      <a href="/admin/plugins/gamification" class="leaderboard__settings">
        {{d-icon "cog"}}
        {{unless
          site.mobileView
          (i18n "gamification.leaderboard.link_to_settings")
        }}
      </a>
    {{/if}}
  </div>

  <div class="leaderboard__controls">
    <PeriodChooser
      @period={{this.period}}
      @action={{action "changePeriod"}}
      @fullDay={{false}}
      class="leaderboard__period-chooser"
      style="display: none"
    />
    {{!-- //增加排行榜年月日的选择 --}}
    <div class="leaderboard__cus-choosers">
      <DButton  class="leaderboard__cus-chooser-active" @action={{action "handleChangePeriod" "all" }}>总榜</DButton>
      <DButton @action={{action "handleChangePeriod" "monthly" }}>月榜</DButton>
      <DButton @action={{action "handleChangePeriod" "weekly" }}>周榜</DButton>
    </div>
  </div>

  {{#if this.isNotReady}}
    <div class="leaderboard__not-ready">
      <p>{{this.model.reason}}</p>
      <DButton
        @icon="sync"
        @label="gamification.leaderboard.refresh"
        @action={{action "refresh"}}
        class="btn-primary refresh"
      />
    </div>
  {{else}}
    <div class="podium__wrapper">
      <div class="podium">
        {{#each winners as |winner|}}
          <div class="winner -position{{winner.position}}">
            {{!-- <div class="winner__crown">{{d-icon "crown"}}</div> --}}
            {{!-- 使用自定义的排名皇冠 --}}
            <div class="winner__crown">
              {{#if winner.position}}
                {{#if (eq winner.position 1)}}
                  <img src="http://www.openkylin.top/public/images/forum/%E6%8E%92%E5%90%8D%E7%AC%AC%E4%B8%80.png" alt="排名第一" />
                {{else if (eq winner.position 2)}}
                  <img src="http://www.openkylin.top/public/images/forum/%E6%8E%92%E5%90%8D%E7%AC%AC%E4%BA%8C.png" alt="排名第二" />
                {{else if (eq winner.position 3)}}
                  <img src="http://www.openkylin.top/public/images/forum/%E6%8E%92%E5%90%8D%E7%AC%AC%E4%B8%89.png" alt="排名第三" />
                {{/if}}
              {{/if}}
            </div>
            <div
              class="winner__avatar clickable"
              role="button"
              data-user-card={{winner.username}}
            >
              {{avatar winner imageSize="huge"}}
              {{!-- <div class="winner__rank">
                <span>{{winner.position}}</span>
              </div> --}}
            </div>
            <div class="winner__name">
              {{#if this.siteSettings.prioritize_username_in_ux}}
                {{winner.username}}
              {{else}}
                {{or winner.name winner.username}}
              {{/if}}
            </div>
            <div class="winner__score">{{fullnumber winner.total_score}}</div>
            <div class="winner__desc">贡献值</div>
          </div>
        {{/each}}
      </div>
    </div>

    <div class="ranking">
      {{!-- <div class="ranking-col-names">
        <span>{{i18n "gamification.leaderboard.rank"}}</span>
        <span>{{d-icon "award"}}{{i18n "gamification.score"}}</span>
      </div> --}}
      <div class="ranking-col-names__sticky-border"></div>
      {{!-- {{#if currentUserRanking.user}}
        <div class="user -self">
          <div class="user__rank">{{currentUserRanking.position}}</div>
          <div class="user__name">{{i18n "gamification.you"}}</div>
          <div class="user__score">
            {{#if site.mobileView}}
              {{number currentUserRanking.user.total_score}}
            {{else}}
              {{fullnumber currentUserRanking.user.total_score}}
            {{/if}}
          </div>
        </div>
      {{/if}} --}}

      <LoadMore @selector=".user" @action={{action "loadMore"}} class="boardRows">
        {{#each ranking as |rank index|}}
          <GamificationLeaderboardRow @rank={{rank}} @index={{index}} />
        {{/each}}
      </LoadMore>
      <ConditionalLoadingSpinner @condition={{loading}} />
    </div>
  {{/if}}
</div>